package com.example.demo.controller;

import com.example.demo.entity.Commdity;
import com.example.demo.impl.CommdityServiceImpl;
import com.example.demo.impl.UserServiceImpl;
import com.example.demo.service.CommdityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/Commdity")
@CrossOrigin(origins="http://localhost:8080")
public class Commditycontroller {
    @Autowired
    CommdityServiceImpl commdityService;

    @GetMapping("/getall")
    public Object findall()
    {
        return commdityService.getList();
    }

    @GetMapping("/getcommditylist")
    public List<Commdity> getcommditylist(int shopid){return commdityService.getcommditylist(shopid);}

    @GetMapping("/findby_id")
    public Object findby_id(int id)
    {
        return commdityService.findby_id(id);
    }
    @GetMapping("/relaid")
    public Object findBy_id(int relaid)
    {
        return commdityService.getrelaidList(relaid);
    }

//    @GetMapping("/id")
//    public Object findBy_goodid(int id)
//    {
//        return commdityService.getidList(id);
//    }



    @PostMapping("/addshoppingcart")
    public boolean addshoppingcart(String username,String objectname,String image,double objectprice)
    {
        commdityService.addshoppingcart(username, objectname, objectprice,image);
        return true;
    }





}
